<?php

function ShowMsg($msg,$redirect='')
{
    if($redirect == 'back')
    {
        echo "<script>alert('$msg');window.history.go(-1);</script>";
    }
    else
    {
        $redirect = $_SERVER["REQUEST_URI"];
        echo "<script>alert('$msg');window.location.href='$redirect';</script>";
    }
}

function safeCheck($str) 
{ 
    $farr = array(
        "/<(\/?)(script|i?frame|style|html|body|title|link|meta|\?|\%)([^>]*?)>/isU",  //过滤 <script 等可能引入恶意内容或恶意改变显示布局的代码,如果不需要插入flash等,还可以加入<object的过滤 
        "/(<[^>]*)on[a-zA-Z]+\s*=([^>]*>)/isU",                                      //过滤javascript的on事件 
      
   ); 
   $tarr = array(
        "", 
        "", 
   ); 

  $str = preg_replace($farr,$tarr,$str); 
   return $str; 
}
?>